﻿//创建时间: 2010-10-11
//创建作者: 李 城
//功能说明: 可选值类型管理 添加 修改
//最后修改: 2010-10-11
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.Web.Admin
{
    public partial class FormInputValueType_save : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_ContentModel;
        }
        #endregion


        #region 页面变量
        FormInputValueTypeManage m_FormInputValueTypeManage = new FormInputValueTypeManage();
        protected int m_id = 0;
        protected string m_title = "添加录入可选值类型";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBase();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string strMSG = "名称 、Key或 级数";
            if (!PageAssist.CheckForm(txtName, ref strMSG) ||
                !PageAssist.CheckForm(txtKeyWord, ref strMSG) ||
                !PageAssist.CheckForm(txtStep, ref strMSG)
                )
            {
                Alert(strMSG);
                return;
            }
            int.TryParse(GetRequestViewState("id"), out m_id);
            FormInputValueTypeInfo oFormInputValueTypeInfo = (FormInputValueTypeInfo)(GetPageViewState("model"));
            if (oFormInputValueTypeInfo == null)
                oFormInputValueTypeInfo = new FormInputValueTypeInfo();
            else
                m_title = oFormInputValueTypeInfo.Name;
            oFormInputValueTypeInfo.Name = txtName.TextTrim.RemoveHtml();
            oFormInputValueTypeInfo.KeyWord = txtKeyWord.TextTrim.RemoveHtml();
            oFormInputValueTypeInfo.Step = txtStep.TextTrim.ToInt();
            oFormInputValueTypeInfo.Description = txtDescription.TextTrim.RemoveHtml();
            SubmitAlertAndParReset(m_FormInputValueTypeManage.Save(oFormInputValueTypeInfo));
        }
        #endregion

        #region 页面方法
        public void LoadBase()
        {
            int.TryParse(InitRequestViewState("id"), out m_id);
            FormInputValueTypeInfo oFormInputValueTypeInfo = m_FormInputValueTypeManage.GetInfoById(m_id);
            if (oFormInputValueTypeInfo != null)
            {
                txtName.Text = oFormInputValueTypeInfo.Name;
                txtKeyWord.Text = oFormInputValueTypeInfo.KeyWord;
                txtStep.Text = oFormInputValueTypeInfo.Step.ToString();
                txtDescription.Text = oFormInputValueTypeInfo.Description;
                InitPageViewState("model", oFormInputValueTypeInfo);
                m_title = oFormInputValueTypeInfo.Name;
                txtKeyWord.Enabled = false;
            }
        }
        #endregion
    }
}
